﻿<phone:PhoneApplicationPage
    x:Class="WinnerSV.Views.SportsView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" 
    xmlns:Command="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:helpers="clr-namespace:WinnerSV.Helpers"
    mc:Ignorable="d"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait"  Orientation="Portrait"
    shell:SystemTray.IsVisible="True"
    DataContext="{Binding Sports, Mode=OneTime, Source={StaticResource Locator}}"
    xmlns:uc="clr-namespace:WinnerSV.Views" >

    <phone:PhoneApplicationPage.Resources>
        <Storyboard x:Name="StoryBoardYUp">
            <DoubleAnimation x:Name="DoubleAnimationUp"
                Duration="0:0:0.7"
                To="0" 
                Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateY)" 
                Storyboard.TargetName="SportsGridAnteprima" 
                d:IsOptimized="True">
                <DoubleAnimation.EasingFunction>
                    <BackEase EasingMode="EaseIn" Amplitude="0.2" />
                </DoubleAnimation.EasingFunction>
            </DoubleAnimation>
        </Storyboard>
        <Storyboard x:Name="StoryBoardYDown">
            <DoubleAnimation x:Name="DoubleAnimationDown"
                Duration="0:0:0.7"
                From="0"
                Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateY)" 
                Storyboard.TargetName="SportsGridAnteprima" 
                d:IsOptimized="True">
                <DoubleAnimation.EasingFunction>
                    <BackEase EasingMode="EaseOut" Amplitude="0.2" />
                </DoubleAnimation.EasingFunction>
            </DoubleAnimation>
        </Storyboard>
    </phone:PhoneApplicationPage.Resources>

    <!-- Progress Indicator-->
    <shell:SystemTray.ProgressIndicator>
        <shell:ProgressIndicator IsIndeterminate="True"
                                 Text="{Binding LocalizedResources.SportsProgressIndicatorText, Mode=OneWay, Source={StaticResource LocalizedStrings}}"
                                 IsVisible="{Binding Path=IsProgressIndicatorVisible}" />
    </shell:SystemTray.ProgressIndicator>

    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot" Background="Transparent">
        <!--Pivot Control-->
        <phone:Pivot x:Name="SportsPivot"
                     Title="{Binding LocalizedResources.ApplicationTitle, Mode=OneWay, Source={StaticResource LocalizedStrings}}" 
                     Height="768" 
                     VerticalAlignment="Bottom" Foreground="{StaticResource paletteWinnerYellowDark}">

            <!-- Pivot Calcio -->
            <phone:PivotItem Header="{Binding LocalizedResources.SportsPivot1Header, Mode=OneWay, Source={StaticResource LocalizedStrings}}">
                <helpers:LongListSelector x:Name="SportsPivotFootball" 
                                          ItemsSource="{Binding GroupedCalcio}"
                                          ItemTemplate="{StaticResource templateSportsLls}"
                                          JumpListStyle="{StaticResource templateSprtsJumpLls}"
                                          GroupHeaderTemplate="{StaticResource templateSportsLlsGroupHeader}" 
                                          LayoutMode="List" 
                                          SelectedItem="{Binding ItemSelected, Mode=TwoWay}" 
                                          Padding="{Binding ActualHeight, ConverterParameter=3, Converter={StaticResource ResizeConverter}, ElementName=LayoutRoot, Mode=OneWay}" 
                                          IsGroupingEnabled="True"
                                          >
                    <i:Interaction.Triggers>
                        <i:EventTrigger EventName="SelectionChanged">
                            <Command:EventToCommand Command="{Binding Path=NavToPageCommand, Mode=OneWay}" />
                        </i:EventTrigger>
                    </i:Interaction.Triggers>
                </helpers:LongListSelector>
            </phone:PivotItem>

            <!-- Pivot Tennis -->
            <phone:PivotItem Header="{Binding LocalizedResources.SportsPivot2Header, Mode=OneWay, Source={StaticResource LocalizedStrings}}">
                <helpers:LongListSelector x:Name="SportsPivotTennis"  
                                          ItemsSource="{Binding GroupedTennis}" 
                                          ItemTemplate="{StaticResource templateSportsLls}"
                                          JumpListStyle="{StaticResource templateSprtsJumpLls}"
                                          GroupHeaderTemplate="{StaticResource templateSportsLlsGroupHeader}" 
                                          LayoutMode="List"
                                          SelectedItem="{Binding ItemSelected, Mode=TwoWay}" 
                                          Padding="{Binding ActualHeight, ConverterParameter=3, Converter={StaticResource ResizeConverter}, ElementName=LayoutRoot, Mode=OneWay}" 
                                          IsGroupingEnabled="True"
                                          >
                    <i:Interaction.Triggers>
                        <i:EventTrigger EventName="SelectionChanged">
                            <Command:EventToCommand Command="{Binding Path=NavToPageCommand, Mode=OneWay}" />
                        </i:EventTrigger>
                    </i:Interaction.Triggers>
                </helpers:LongListSelector>
            </phone:PivotItem>

            <!-- Pivot Basket -->
            <phone:PivotItem Header="{Binding LocalizedResources.SportsPivot3Header, Mode=OneWay, Source={StaticResource LocalizedStrings}}">
                <helpers:LongListSelector x:Name="SportsPivotBasket"
                                          ItemsSource="{Binding GroupedBasket}"
                                          ItemTemplate="{StaticResource templateSportsLls}"
                                          JumpListStyle="{StaticResource templateSprtsJumpLls}"
                                          GroupHeaderTemplate="{StaticResource templateSportsLlsGroupHeader}" 
                                          LayoutMode="List"
                                          SelectedItem="{Binding ItemSelected, Mode=TwoWay}" 
                                          Padding="{Binding ActualHeight, ConverterParameter=3, Converter={StaticResource ResizeConverter}, ElementName=LayoutRoot, Mode=OneWay}" 
                                          IsGroupingEnabled="True"
                                          >
                    <i:Interaction.Triggers>
                        <i:EventTrigger EventName="SelectionChanged">
                            <Command:EventToCommand Command="{Binding Path=NavToPageCommand, Mode=OneWay}" />
                        </i:EventTrigger>
                    </i:Interaction.Triggers>
                </helpers:LongListSelector>
            </phone:PivotItem>
        </phone:Pivot>

        <!-- Scheda scorrevole con anteprima della Schedina -->
        <Grid x:Name="SportsGridAnteprima" 
              VerticalAlignment="Bottom"
              Height="{Binding ActualHeight, Converter={StaticResource ResizeConverter}, ElementName=LayoutRoot, Mode=OneWay, ConverterParameter=1}" 
              RenderTransformOrigin="0.5,0.5" 
              ManipulationStarted="SportsGridAnteprima_ManipulationStarted"
              ManipulationDelta="SportsGridAnteprima_ManipulationDelta"
              ManipulationCompleted="SportsGridAnteprima_ManipulationCompleted"
              Tap="SportsGridAnteprima_Tap"
              UseOptimizedManipulationRouting="False" >
            <Grid.Background>
                <SolidColorBrush Color="White"/>
            </Grid.Background>
            <Grid.RenderTransform>
                <CompositeTransform TranslateY="{Binding ActualHeight, ConverterParameter=2, Converter={StaticResource ResizeConverter}, ElementName=LayoutRoot, Mode=OneWay}" />
            </Grid.RenderTransform>

            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="*" />
            </Grid.RowDefinitions>

            <TextBlock Grid.Row="0"
                       Padding="10"
                       Text="{Binding AnteSchedina.SelectedSchedina.Title, Source={StaticResource Locator}}" 
                       FontSize="{StaticResource PhoneFontSizeLarge}" 
                       TextTrimming="WordEllipsis" Foreground="Black"/>
            <uc:AnteprimaSchedina Grid.Row="0" Grid.RowSpan="2"
                                  Margin="{Binding ActualHeight, ConverterParameter=4, Converter={StaticResource ResizeConverter}, ElementName=LayoutRoot, Mode=OneWay}" />

        </Grid>
    </Grid>

</phone:PhoneApplicationPage>